package com.ly.controller;

import com.ly.pojo.Products;
import com.ly.service.ProductionService;
import lombok.experimental.Accessors;
import org.omg.CORBA.PUBLIC_MEMBER;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/production")
public class ProductionController {
    @Autowired
    private ProductionService productionService;
    @Value("${server.port}")
    private String port;

    @RequestMapping("/findProductionById/{id}")
    public Products findProductionById(@PathVariable("id") Integer id) {
        return productionService.findById(id);
    }

    @RequestMapping("/findAllProduction")
    public List<Products> findAllProduction() {
        List<Products> allProduction = productionService.findAllProduction();
        return allProduction;
    }
    @GetMapping("/getPort")
    public String getPort(){
        return this.port;
    }
}
